﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using db = DataContext;

namespace WebApplication
{
	public partial class News : System.Web.UI.Page
	{
		public int id;

		protected void Page_Load(object sender, EventArgs e)
		{
			id = Common.Id;

			using (db.DbDataContext context = new db.DbDataContext())
			{
				if (id == 0)
				{
					news_list.DataSource = context.News.Skip(Common.Start).Take(news_pager.Limit);
					news_list.DataBind();
				} else
				{
					db.News news = context.News.Single(x => x.Id == id);
					news_title.Text = news.Title;
					news_info.Text = news.Author + " delivered on " + news.AddTime.ToShortDateString();
					aa.InnerHtml = news.Content;
				}
			}
		}
	}
}